package com.b2j.routines;

import com.b2j.base.ErrorManager;
import com.b2j.base.Lexema;
import com.b2j.base.MainTools;
import com.b2j.base.Routine;
import com.b2j.base.Token;

public class Key extends Routine {

	@Override
	public String generate(Lexema lexema) {
		
		String line = "JDiv.input.key(Keys.";
		String key = "";

		if (MainTools.tools.currentProcess.imports.indexOf("import com.badlogic.gdx.Input.Keys;") < 0)
			MainTools.tools.currentProcess.imports.add("import com.badlogic.gdx.Input.Keys;");

		lexema = MainTools.tools.nextLexema();
		if (lexema.tokenType == Token.OPARENT) {

			lexema = MainTools.tools.nextLexema();
			if (lexema.tokenType == Token.ID) {
				key = lexema.lexema;
				key = key.substring(1, key.length()).toUpperCase();
			} else {
				ErrorManager.unexpected(lexema);
			}

			lexema = MainTools.tools.nextLexema();
			
		} else {
			ErrorManager.unexpected(lexema);
		}
		
		line = line + key + ")";
		return line;
	}

}
